package utils;

import java.awt.geom.Point2D;

public class Vector2D {
	public double x;
	public double y;
	public Vector2D(double x, double y) {
		this.x = x;
		this.y = y;
	}
	public Vector2D(Point2D point1, Point2D point2) {
		this.x = point2.getX() - point1.getX();
		this.y = point2.getY() - point2.getY();
	}
	public double angleBetween(Vector2D otherVector) {
		return Math.acos(this.x*otherVector.x + this.y*otherVector.y);
	}
	public Vector2D getOrthogonalUnitVector() {
		Vector2D orthVec = new Vector2D(y, -x);
		orthVec.normalize();
		return orthVec;
	}
	public void scale(double scale) {
		this.x *= scale;
		this.y *= scale;
	}
	public void normalize() {
		double mag = Math.sqrt(x*x + y*y);
		x = x/mag;
		y = y/mag;
	}

}
